package main

import "math"

func lengthOfLongestSubstring(s string) int {

	r, slen, ans := -1, len(s), 0
	m := map[byte]int{}

	for i := 0; i < slen; i++ {
		if i != 0 {
			delete(m, s[i-1])
		}
		for r+1 < slen && m[s[r+1]] == 0 {
			m[s[r+1]]++
			r++
		}
		ans = int(math.Max(float64(ans), float64(r-i+1)))
	}
	return ans
}

func main() {

}
